package utils

import (
	"time"
)

type (
	TimeStampUTC    uint32
	TimeStampUTCRaw [4]byte
)

func NewTimeStampUTC() TimeStampUTC {
	t := time.Now().Unix()
	d := NumberToBytesWithBigEndian(t)
	return BytesToNumber[TimeStampUTC](d[:])
}

func (ts TimeStampUTC) ToInt64() int64 {
	return int64(ts)
}

func (ts TimeStampUTC) Raw() (out TimeStampUTCRaw) {
	copy(out[:], NumberToBytesWithBigEndian(ts))
	return
}

func (ts TimeStampUTCRaw) Type() TimeStampUTC {
	return BytesToNumber[TimeStampUTC](ts[:])
}

func (ts TimeStampUTCRaw) Slice() []byte {
	return ts[:]
}
